###############################################################################
# FileName      : do_parted.sh
# Description   : parted all disks for ceph OSD
# Author        ：fanxiaoguang(fanxiaoguang@zettakit.com/solar_ambitious@126.com)
# Date          : 2016/03/31
###############################################################################

#!/bin/bash

set -e
if [ ! -x "/sbin/parted" ]; then
    echo "This script requires /sbin/parted to run!" >&2
    exit 1
fi

#DISKS="b c d e f g h"
#for i in ${DISKS}; do
#    echo "Creating partitions on /dev/sd${i} ..."
#    parted -a optimal --script /dev/sd${i} -- mktable gpt
#    sleep 1
#    parted -a optimal --script /dev/sd${i} -- mkpart primary xfs 0% 100%
#    sleep 1
#    echo "Formatting xfs /dev/sd${i}1 ..."
#    mkfs.xfs -f /dev/sd${i}1 &
#done
#
NVMES="nvme0n1 nvme1n1"
for i in ${NVMES}; do
    echo "Creating partitions on /dev/${i} ..."
    parted -s /dev/${i} mklabel gpt
    sleep 1
    parted -s /dev/${i} mkpart primary 0% 25%
    sleep 1
    parted -s /dev/${i} mkpart primary 25% 50%
    sleep 1
    parted -s /dev/${i} mkpart primary 50% 75%
    sleep 1
    parted -s /dev/${i} mkpart primary 75% 100%
    sleep 1
    #echo "Formatting xfs /dev/${i}p1 ..."
    #mkfs.xfs -f /dev/${i}p1 &
done

exit
SSDS="l m"
for i in ${SSDS}; do
    parted -s /dev/sd${i} mklabel gpt
    echo "parted /dev/sd${i}1 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 0% 10%
    echo "parted /dev/sd${i}2 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 10% 20%
    echo "parted /dev/sd${i}3 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 20% 30%
    echo "parted /dev/sd${i}4 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 30% 40%
    echo "parted /dev/sd${i}5 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 40% 50%
    echo "parted /dev/sd${i}6 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 50% 60%
    echo "parted /dev/sd${i}7 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 60% 70%
    echo "parted /dev/sd${i}8 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 70% 80%
    echo "parted /dev/sd${i}9 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 80% 90%
    echo "parted /dev/sd${i}10 ..."
    sleep 1
    parted -s /dev/sd${i} mkpart primary 90% 100%
done
